<template>
  <div class="app-container">
   <!-- <searchForm
     :formOptions="formOptions"
     @onSearch="onSearch"
     @onReset="onReset"
     :formLabelWidth="formLabelWidth"
     v-show="showSearch"
   />
   <el-row :gutter="10" class="mb8">
     <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
   </el-row> -->
   <el-table :data="tableData" v-loading="loading">
      <el-table-column label="上传文件名称" prop="importName" :show-overflow-tooltip="true" align="center" />
      <el-table-column label="上传模块" prop="modeValue" align="center">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.import_mode" :value="scope.row.modeValue"></dict-tag>
        </template>
      </el-table-column>
      <el-table-column label="上传时间" :show-overflow-tooltip="true" prop="createTime" align="center">
      </el-table-column>
      <el-table-column label="上传状态" :show-overflow-tooltip="true" prop="status" align="center">
          <template slot-scope="{row}">
              <span v-if="row.status == '1'">待上传</span>
              <span v-if="row.status == '2'">上传中</span>
              <span v-if="row.status == '3'">上传完成</span>
          </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
                size="mini"
                type="text"
                @click="downloadFile(scope.row)"
            >下载上传结果</el-button>
          </template>
      </el-table-column>
   </el-table>
   <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { 
  uploadList
} from "@/api/system/uploadRecord.js";
// import searchForm from "@/components/Search/searchForm.vue";
import {downloadGet} from '@/utils/request'
export default {
   name:"uploadRecord",
   components: { 
    // searchForm
   },
   dicts: ["import_mode"],
   data () {
       return{
           // 显示搜索条件
           showSearch: true,
           formLabelWidth: "100px",
           formOptions:[{
            label: "导入文件名称",
            prop: "importName",
            element: "el-input",
            placeholder: "请输入导入文件名称",
           }],
           // 查询参数
           queryParams: {
            pageNum: 1,
            pageSize: 10,
           },
           tableData: [],
           total: 0,
           // 遮罩层
           loading: true,
       }
   },
   computed:{
       
   },
   created(){
      this.getList()
   },
   methods:{
       onSearch(val) {
          this.queryParams = Object.assign(this.queryParams, val);
          this.getList();
       },
        // 重置
       onReset(data) {
          this.queryParams = Object.assign(this.queryParams, data);
          this.getList();
       },
       getList () {
          uploadList(this.queryParams).then((res) => {
            this.tableData = res.rows
            this.total = res.total
            this.loading = false;
          })  
       },
       downloadFile(row) {
        if (row.resultPath) {
          downloadGet(
            "/common/downloadV2",
            {
              params:{
                fileName: row.resultPath
              }
            },
            下载结果
          );
        } else {
          this.$modal.msgWarning("未找到上传结果");
        }
       }
   }
}
</script>

<style>

</style>